Skip to main content

User Op

UserOperation (UserOp) Structure

The UserOperation struct is a fundamental component of the Account Abstraction system. Here's the detailed structure with explanations:

struct UserOperation {
address sender; // The account making the operation
uint256 nonce; // Anti-replay parameter
bytes initCode; // Code to create new account (empty for existing)
bytes callData; // The data to pass to the sender during execution
uint256 callGasLimit; // Gas limit for the main execution call
uint256 verificationGasLimit; // Gas limit for the verification step
uint256 preVerificationGas; // Extra gas to pay the bundler
uint256 maxFeePerGas; // Maximum fee per gas (similar to EIP-1559)
uint256 maxPriorityFeePerGas; // Maximum priority fee per gas
bytes paymasterAndData; // Paymaster address and data (if used)
bytes signature; // Data to verify authorization
}

Differences between UserOp v6 and PackedUserOp v7

  1. Structure and Packing:

    • v6 UserOp: Used the full structure as shown above.
    • v7 PackedUserOp: Introduces a more gas-efficient packed version for on-chain use.
  2. Field Consolidation in v7:

    • initCode: Combines factory and factoryData into a single bytes field.
    • accountGasLimits: Packs verificationGasLimit and callGasLimit into a single bytes32.
    • gasFees: Combines maxPriorityFeePerGas and maxFeePerGas into a single bytes32.
    • paymasterAndData: Consolidates all paymaster-related fields.
  3. Paymaster Handling:

    • v6: Separate fields for paymaster address and data.
    • v7: Combines paymaster information into paymasterAndData.
  4. Gas Limit Representation:

    • v6: Separate uint256 fields for different gas limits.
    • v7: Uses packed bytes32 for gas limits, improving gas efficiency.
  5. Nonce Management:

    • v6: Basic nonce field.
    • v7: May include improvements in nonce handling (though not explicitly changed in the struct) may Add validator to be used as a key.
  6. Signature Field:

    • Remains similar in both versions, but v7 might have enhanced security considerations.

PackedUserOp v7 Structure

Here's a representation of how the PackedUserOp in v7 might look:

struct PackedUserOperation {
address sender;
uint256 nonce;
bytes initCode;
bytes callData;
bytes32 accountGasLimits; // Packed verificationGasLimit and callGasLimit
uint256 preVerificationGas;
bytes32 gasFees; // Packed maxPriorityFeePerGas and maxFeePerGas
bytes paymasterAndData;
bytes signature;
}

Key Improvements in v7

  1. Gas Efficiency: The packed structure in v7 reduces the gas cost for storing and processing UserOperations on-chain.

  2. Simplified On-Chain Handling: By consolidating fields, v7 simplifies the process of unpacking and using the data within smart contracts.

  3. Flexibility: The packed format allows for easier future extensions without changing the core structure.

  4. Optimized Storage: Reduces the storage footprint of UserOperations in contract memory and storage.

These changes in v7 reflect a focus on optimizing gas usage and improving the overall efficiency of the Account Abstraction system, while maintaining the core functionality established in v6.

INFO

Refer to EIP 4337 Using Alt Mempool for better Understanding